<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-2"></span><span class="hs-comment">--</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Code generation for foreign calls.</span><span>
</span><span id="line-4"></span><span class="hs-comment">--</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- (c) The University of Glasgow 2004-2006</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.StgToCmm.Foreign</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-10"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#cgForeignCall"><span class="hs-identifier">cgForeignCall</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-11"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitPrimCall"><span class="hs-identifier">emitPrimCall</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitCCall"><span class="hs-identifier">emitCCall</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier">emitForeignCall</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitSaveThreadState"><span class="hs-identifier">emitSaveThreadState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#saveThreadState"><span class="hs-identifier">saveThreadState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitLoadThreadState"><span class="hs-identifier">emitLoadThreadState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitSaveRegs"><span class="hs-identifier">emitSaveRegs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitRestoreRegs"><span class="hs-identifier">emitRestoreRegs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#loadThreadState"><span class="hs-identifier">loadThreadState</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitOpenNursery"><span class="hs-identifier">emitOpenNursery</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>  </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitCloseNursery"><span class="hs-identifier">emitCloseNursery</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Enum.html#succ"><span class="hs-identifier">succ</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator">(&lt;*&gt;)</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html"><span class="hs-identifier">GHC.Stg.Syntax</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html"><span class="hs-identifier">GHC.StgToCmm.Prof</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Prof.html#storeCurCCS"><span class="hs-identifier">storeCurCCS</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html#ccsType"><span class="hs-identifier">ccsType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Env.html"><span class="hs-identifier">GHC.StgToCmm.Env</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html"><span class="hs-identifier">GHC.StgToCmm.Monad</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Utils.html"><span class="hs-identifier">GHC.StgToCmm.Utils</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html"><span class="hs-identifier">GHC.StgToCmm.Closure</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Layout.html"><span class="hs-identifier">GHC.StgToCmm.Layout</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier">newBlockId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html"><span class="hs-identifier">GHC.Cmm.Graph</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.CallConv.html"><span class="hs-identifier">GHC.Cmm.CallConv</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.RepType.html"><span class="hs-identifier">GHC.Types.RepType</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.CLabel.html"><span class="hs-identifier">GHC.Cmm.CLabel</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html"><span class="hs-identifier">GHC.Runtime.Heap.Layout</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html"><span class="hs-identifier">GHC.Types.ForeignCall</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Misc.html#zipEqual"><span class="hs-identifier">zipEqual</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- Code generation for Foreign Calls</span><span>
</span><span id="line-58"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="hs-comment">-- | Emit code for a foreign call, and return the results to the sequel.</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- Precondition: the length of the arguments list is the same as the</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- arity of the foreign function.</span><span>
</span><span id="line-63"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#cgForeignCall"><span class="hs-identifier hs-type">cgForeignCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#ForeignCall"><span class="hs-identifier hs-type">ForeignCall</span></a></span><span>            </span><span class="hs-comment">-- the op</span><span>
</span><span id="line-64"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                   </span><span class="hs-comment">-- type of foreign function</span><span>
</span><span id="line-65"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span>               </span><span class="hs-comment">-- x,y    arguments</span><span>
</span><span id="line-66"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>                   </span><span class="hs-comment">-- result type</span><span>
</span><span id="line-67"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span id="cgForeignCall"><span class="annot"><span class="annottext">cgForeignCall :: ForeignCall -&gt; Type -&gt; [StgArg] -&gt; Type -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#cgForeignCall"><span class="hs-identifier hs-var hs-var">cgForeignCall</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCall"><span class="hs-identifier hs-type">CCall</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallSpec"><span class="hs-identifier hs-type">CCallSpec</span></a></span><span> </span><span id="local-6989586621681057151"><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681057151"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621681057150"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681057150"><span class="hs-identifier hs-var">cconv</span></a></span></span><span> </span><span id="local-6989586621681057149"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057149"><span class="hs-identifier hs-var">safety</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681057148"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681057148"><span class="hs-identifier hs-var">typ</span></a></span></span><span> </span><span id="local-6989586621681057147"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681057147"><span class="hs-identifier hs-var">stg_args</span></a></span></span><span> </span><span id="local-6989586621681057146"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681057146"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-70"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681057145"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057145"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-71"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- in the stdcall calling convention, the symbol needs @size appended</span><span>
</span><span id="line-72"></span><span>              </span><span class="hs-comment">-- to it, where size is the total number of bytes of arguments.  We</span><span>
</span><span id="line-73"></span><span>              </span><span class="hs-comment">-- attach this info to the CLabel here, and the CLabel pretty printer</span><span>
</span><span id="line-74"></span><span>              </span><span class="hs-comment">-- will generate the suffix when the label is printed.</span><span>
</span><span id="line-75"></span><span>            </span><span id="local-6989586621681057140"><span class="annot"><span class="annottext">call_size :: [(CmmExpr, b)] -&gt; Maybe ByteOff
</span><a href="#local-6989586621681057140"><span class="hs-identifier hs-var hs-var">call_size</span></a></span></span><span> </span><span id="local-6989586621681057139"><span class="annot"><span class="annottext">[(CmmExpr, b)]
</span><a href="#local-6989586621681057139"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-76"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#StdCallConv"><span class="hs-identifier hs-var">StdCallConv</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681057150"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteOff -&gt; Maybe ByteOff
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ByteOff] -&gt; ByteOff
forall (t :: * -&gt; *) a. (Foldable t, Num a) =&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#sum"><span class="hs-identifier hs-var">sum</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((CmmExpr, b) -&gt; ByteOff) -&gt; [(CmmExpr, b)] -&gt; [ByteOff]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmExpr, b) -&gt; ByteOff
forall {b}. (CmmExpr, b) -&gt; ByteOff
</span><a href="#local-6989586621681057136"><span class="hs-identifier hs-var">arg_size</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, b)]
</span><a href="#local-6989586621681057139"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe ByteOff
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span>              </span><span class="hs-comment">-- ToDo: this might not be correct for 64-bit API</span><span>
</span><span id="line-80"></span><span>              </span><span class="hs-comment">-- This is correct for the PowerPC ELF ABI version 1 and 2.</span><span>
</span><span id="line-81"></span><span>            </span><span id="local-6989586621681057136"><span class="annot"><span class="annottext">arg_size :: (CmmExpr, b) -&gt; ByteOff
</span><a href="#local-6989586621681057136"><span class="hs-identifier hs-var hs-var">arg_size</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681057133"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057133"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteOff -&gt; ByteOff -&gt; ByteOff
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">max</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; ByteOff
</span><a href="GHC.Cmm.Type.html#widthInBytes"><span class="hs-identifier hs-var">widthInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">(Width -&gt; ByteOff) -&gt; Width -&gt; ByteOff
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmType -&gt; Width) -&gt; CmmType -&gt; Width
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmType
</span><a href="GHC.Cmm.Expr.html#cmmExprType"><span class="hs-identifier hs-var">cmmExprType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057145"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057133"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span>                                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; ByteOff
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057145"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681057127"><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057127"><span class="hs-identifier hs-var">cmm_args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[StgArg] -&gt; Type -&gt; FCode [(CmmExpr, ForeignHint)]
</span><a href="GHC.StgToCmm.Foreign.html#getFCallArgs"><span class="hs-identifier hs-var">getFCallArgs</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681057147"><span class="hs-identifier hs-var">stg_args</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681057148"><span class="hs-identifier hs-var">typ</span></a></span><span>
</span><span id="line-84"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681057125"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057125"><span class="hs-identifier hs-var">res_regs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057124"><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057124"><span class="hs-identifier hs-var">res_hints</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; FCode ([LocalReg], [ForeignHint])
</span><a href="GHC.StgToCmm.Utils.html#newUnboxedTupleRegs"><span class="hs-identifier hs-var">newUnboxedTupleRegs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681057146"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-85"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681057122"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057122"><span class="hs-identifier hs-var">call_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057121"><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057121"><span class="hs-identifier hs-var">arg_hints</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057120"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057120"><span class="hs-identifier hs-var">cmm_target</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681057151"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-87"></span><span>                   </span><span class="annot"><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-type">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Maybe Unit
</span><span class="hs-identifier">_</span></span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-88"></span><span>                       </span><span class="annot"><span class="annottext">String -&gt; (([CmmExpr], [ForeignHint]), CmmExpr)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgForeignCall: unexpected FFI value import&quot;</span></span><span>
</span><span id="line-89"></span><span>                   </span><span class="annot"><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-type">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681057117"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681057117"><span class="hs-identifier hs-var">lbl</span></a></span></span><span> </span><span id="local-6989586621681057116"><span class="annot"><span class="annottext">Maybe Unit
</span><a href="#local-6989586621681057116"><span class="hs-identifier hs-var">mPkgId</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-90"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681057115"><span class="annot"><span class="annottext">labelSource :: ForeignLabelSource
</span><a href="#local-6989586621681057115"><span class="hs-identifier hs-var hs-var">labelSource</span></a></span></span><span>
</span><span id="line-91"></span><span>                                </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Unit
</span><a href="#local-6989586621681057116"><span class="hs-identifier hs-var">mPkgId</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-92"></span><span>                                        </span><span class="annot"><span class="annottext">Maybe Unit
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ForeignLabelSource
</span><a href="GHC.Cmm.CLabel.html#ForeignLabelInThisPackage"><span class="hs-identifier hs-var">ForeignLabelInThisPackage</span></a></span><span>
</span><span id="line-93"></span><span>                                        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681057113"><span class="annot"><span class="annottext">Unit
</span><a href="#local-6989586621681057113"><span class="hs-identifier hs-var">pkgId</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Unit -&gt; ForeignLabelSource
</span><a href="GHC.Cmm.CLabel.html#ForeignLabelInPackage"><span class="hs-identifier hs-var">ForeignLabelInPackage</span></a></span><span> </span><span class="annot"><span class="annottext">Unit
</span><a href="#local-6989586621681057113"><span class="hs-identifier hs-var">pkgId</span></a></span><span>
</span><span id="line-94"></span><span>                            </span><span id="local-6989586621681057111"><span class="annot"><span class="annottext">size :: Maybe ByteOff
</span><a href="#local-6989586621681057111"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)] -&gt; Maybe ByteOff
forall {b}. [(CmmExpr, b)] -&gt; Maybe ByteOff
</span><a href="#local-6989586621681057140"><span class="hs-identifier hs-var">call_size</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057127"><span class="hs-identifier hs-var">cmm_args</span></a></span><span>
</span><span id="line-95"></span><span>                        </span><span class="hs-keyword">in</span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)] -&gt; ([CmmExpr], [ForeignHint])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057127"><span class="hs-identifier hs-var">cmm_args</span></a></span><span>
</span><span id="line-96"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabel -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmLabel"><span class="hs-identifier hs-var">CmmLabel</span></a></span><span>
</span><span id="line-97"></span><span>                                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString
-&gt; Maybe ByteOff -&gt; ForeignLabelSource -&gt; FunctionOrData -&gt; CLabel
</span><a href="GHC.Cmm.CLabel.html#mkForeignLabel"><span class="hs-identifier hs-var">mkForeignLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681057117"><span class="hs-identifier hs-var">lbl</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe ByteOff
</span><a href="#local-6989586621681057111"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignLabelSource
</span><a href="#local-6989586621681057115"><span class="hs-identifier hs-var">labelSource</span></a></span><span> </span><span class="annot"><span class="annottext">FunctionOrData
</span><a href="GHC.Types.Basic.html#IsFunction"><span class="hs-identifier hs-var">IsFunction</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span>                   </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="GHC.Types.ForeignCall.html#DynamicTarget"><span class="hs-identifier hs-var">DynamicTarget</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057127"><span class="hs-identifier hs-var">cmm_args</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-100"></span><span>                                           </span><span class="hs-special">(</span><span id="local-6989586621681057104"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057104"><span class="hs-identifier hs-var">fn</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">ForeignHint
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681057103"><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057103"><span class="hs-identifier hs-var">rest</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)] -&gt; ([CmmExpr], [ForeignHint])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057103"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057104"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span>                                           </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; (([CmmExpr], [ForeignHint]), CmmExpr)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cgForeignCall []&quot;</span></span><span>
</span><span id="line-102"></span><span>              </span><span id="local-6989586621681057102"><span class="annot"><span class="annottext">fc :: ForeignConvention
</span><a href="#local-6989586621681057102"><span class="hs-identifier hs-var hs-var">fc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv
-&gt; [ForeignHint]
-&gt; [ForeignHint]
-&gt; CmmReturnInfo
-&gt; ForeignConvention
</span><a href="GHC.Cmm.Node.html#ForeignConvention"><span class="hs-identifier hs-var">ForeignConvention</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681057150"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057121"><span class="hs-identifier hs-var">arg_hints</span></a></span><span> </span><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057124"><span class="hs-identifier hs-var">res_hints</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReturnInfo
</span><a href="GHC.Cmm.Node.html#CmmMayReturn"><span class="hs-identifier hs-var">CmmMayReturn</span></a></span><span>
</span><span id="line-103"></span><span>              </span><span id="local-6989586621681057099"><span class="annot"><span class="annottext">call_target :: ForeignTarget
</span><a href="#local-6989586621681057099"><span class="hs-identifier hs-var hs-var">call_target</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; ForeignConvention -&gt; ForeignTarget
</span><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-var">ForeignTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057120"><span class="hs-identifier hs-var">cmm_target</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignConvention
</span><a href="#local-6989586621681057102"><span class="hs-identifier hs-var">fc</span></a></span><span>
</span><span id="line-104"></span><span>
</span><span id="line-105"></span><span>        </span><span class="hs-comment">-- we want to emit code for the call, and then emitReturn.</span><span>
</span><span id="line-106"></span><span>        </span><span class="hs-comment">-- However, if the sequel is AssignTo, we shortcut a little</span><span>
</span><span id="line-107"></span><span>        </span><span class="hs-comment">-- and generate a foreign call that assigns the results</span><span>
</span><span id="line-108"></span><span>        </span><span class="hs-comment">-- directly.  Otherwise we end up generating a bunch of</span><span>
</span><span id="line-109"></span><span>        </span><span class="hs-comment">-- useless &quot;r = r&quot; assignments, which are not merely annoying:</span><span>
</span><span id="line-110"></span><span>        </span><span class="hs-comment">-- they prevent the common block elimination from working correctly</span><span>
</span><span id="line-111"></span><span>        </span><span class="hs-comment">-- in the case of a safe foreign call.</span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-comment">-- See Note [safe foreign call convention]</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-114"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681057097"><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681057097"><span class="hs-identifier hs-var">sequel</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Sequel
</span><a href="GHC.StgToCmm.Monad.html#getSequel"><span class="hs-identifier hs-var">getSequel</span></a></span><span>
</span><span id="line-115"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681057097"><span class="hs-identifier hs-var">sequel</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-116"></span><span>            </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#AssignTo"><span class="hs-identifier hs-type">AssignTo</span></a></span><span> </span><span id="local-6989586621681057094"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057094"><span class="hs-identifier hs-var">assign_to_these</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-117"></span><span>                </span><span class="annot"><span class="annottext">Safety
-&gt; [LocalReg] -&gt; ForeignTarget -&gt; [CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-var">emitForeignCall</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057149"><span class="hs-identifier hs-var">safety</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057094"><span class="hs-identifier hs-var">assign_to_these</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057099"><span class="hs-identifier hs-var">call_target</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057122"><span class="hs-identifier hs-var">call_args</span></a></span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span>            </span><span id="local-6989586621681057093"><span class="annot"><span class="annottext">Sequel
</span><a href="#local-6989586621681057093"><span class="hs-identifier hs-var">_something_else</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-120"></span><span>                </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Safety
-&gt; [LocalReg] -&gt; ForeignTarget -&gt; [CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-var">emitForeignCall</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057149"><span class="hs-identifier hs-var">safety</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057125"><span class="hs-identifier hs-var">res_regs</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057099"><span class="hs-identifier hs-var">call_target</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057122"><span class="hs-identifier hs-var">call_args</span></a></span><span>
</span><span id="line-121"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Layout.html#emitReturn"><span class="hs-identifier hs-var">emitReturn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmExpr) -&gt; [LocalReg] -&gt; [CmmExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmReg -&gt; CmmExpr) -&gt; (LocalReg -&gt; CmmReg) -&gt; LocalReg -&gt; CmmExpr
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057125"><span class="hs-identifier hs-var">res_regs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>                   </span><span class="hs-special">}</span><span>
</span><span id="line-123"></span><span>         </span><span class="hs-special">}</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-comment">{- Note [safe foreign call convention]

The simple thing to do for a safe foreign call would be the same as an
unsafe one: just

    emitForeignCall ...
    emitReturn ...

but consider what happens in this case

   case foo x y z of
     (# s, r #) -&gt; ...

The sequel is AssignTo [r].  The call to newUnboxedTupleRegs picks [r]
as the result reg, and we generate

  r = foo(x,y,z) returns to L1  -- emitForeignCall
 L1:
  r = r  -- emitReturn
  goto L2
L2:
  ...

Now L1 is a proc point (by definition, it is the continuation of the
safe foreign call).  If L2 does a heap check, then L2 will also be a
proc point.

Furthermore, the stack layout algorithm has to arrange to save r
somewhere between the call and the jump to L1, which is annoying: we
would have to treat r differently from the other live variables, which
have to be saved *before* the call.

So we adopt a special convention for safe foreign calls: the results
are copied out according to the NativeReturn convention by the call,
and the continuation of the call should copyIn the results.  (The
copyOut code is actually inserted when the safe foreign call is
lowered later).  The result regs attached to the safe foreign call are
only used temporarily to hold the results before they are copied out.

We will now generate this:

  r = foo(x,y,z) returns to L1
 L1:
  r = R1  -- copyIn, inserted by mkSafeCall
  goto L2
 L2:
  ... r ...

And when the safe foreign call is lowered later (see Note [lower safe
foreign calls]) we get this:

  suspendThread()
  r = foo(x,y,z)
  resumeThread()
  R1 = r  -- copyOut, inserted by lowerSafeForeignCall
  jump L1
 L1:
  r = R1  -- copyIn, inserted by mkSafeCall
  goto L2
 L2:
  ... r ...

Now consider what happens if L2 does a heap check: the Adams
optimisation kicks in and commons up L1 with the heap-check
continuation, resulting in just one proc point instead of two. Yay!
-}</span><span>
</span><span id="line-191"></span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitCCall"><span class="hs-identifier hs-type">emitCCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmFormal"><span class="hs-identifier hs-type">CmmFormal</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Type.html#ForeignHint"><span class="hs-identifier hs-type">ForeignHint</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-194"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-195"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmActual"><span class="hs-identifier hs-type">CmmActual</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Cmm.Type.html#ForeignHint"><span class="hs-identifier hs-type">ForeignHint</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-196"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span id="emitCCall"><span class="annot"><span class="annottext">emitCCall :: [(LocalReg, ForeignHint)]
-&gt; CmmExpr -&gt; [(CmmExpr, ForeignHint)] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitCCall"><span class="hs-identifier hs-var hs-var">emitCCall</span></a></span></span><span> </span><span id="local-6989586621681057086"><span class="annot"><span class="annottext">[(LocalReg, ForeignHint)]
</span><a href="#local-6989586621681057086"><span class="hs-identifier hs-var">hinted_results</span></a></span></span><span> </span><span id="local-6989586621681057085"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057085"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621681057084"><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057084"><span class="hs-identifier hs-var">hinted_args</span></a></span></span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode ReturnKind -&gt; FCode ()
forall (f :: * -&gt; *) a. Functor f =&gt; f a -&gt; f ()
</span><a href="../../base/src/Data.Functor.html#void"><span class="hs-identifier hs-var">void</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode ReturnKind -&gt; FCode ()) -&gt; FCode ReturnKind -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
-&gt; [LocalReg] -&gt; ForeignTarget -&gt; [CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-var">emitForeignCall</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="GHC.Types.ForeignCall.html#PlayRisky"><span class="hs-identifier hs-var">PlayRisky</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057081"><span class="hs-identifier hs-var">results</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057080"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057079"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-199"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681057079"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057079"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057078"><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057078"><span class="hs-identifier hs-var">arg_hints</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)] -&gt; ([CmmExpr], [ForeignHint])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681057084"><span class="hs-identifier hs-var">hinted_args</span></a></span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681057081"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057081"><span class="hs-identifier hs-var">results</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057077"><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057077"><span class="hs-identifier hs-var">result_hints</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(LocalReg, ForeignHint)] -&gt; ([LocalReg], [ForeignHint])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(LocalReg, ForeignHint)]
</span><a href="#local-6989586621681057086"><span class="hs-identifier hs-var">hinted_results</span></a></span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621681057080"><span class="annot"><span class="annottext">target :: ForeignTarget
</span><a href="#local-6989586621681057080"><span class="hs-identifier hs-var hs-var">target</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; ForeignConvention -&gt; ForeignTarget
</span><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-var">ForeignTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057085"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignConvention
</span><a href="#local-6989586621681057076"><span class="hs-identifier hs-var">fc</span></a></span><span>
</span><span id="line-203"></span><span>    </span><span id="local-6989586621681057076"><span class="annot"><span class="annottext">fc :: ForeignConvention
</span><a href="#local-6989586621681057076"><span class="hs-identifier hs-var hs-var">fc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv
-&gt; [ForeignHint]
-&gt; [ForeignHint]
-&gt; CmmReturnInfo
-&gt; ForeignConvention
</span><a href="GHC.Cmm.Node.html#ForeignConvention"><span class="hs-identifier hs-var">ForeignConvention</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span> </span><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057078"><span class="hs-identifier hs-var">arg_hints</span></a></span><span> </span><span class="annot"><span class="annottext">[ForeignHint]
</span><a href="#local-6989586621681057077"><span class="hs-identifier hs-var">result_hints</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReturnInfo
</span><a href="GHC.Cmm.Node.html#CmmMayReturn"><span class="hs-identifier hs-var">CmmMayReturn</span></a></span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitPrimCall"><span class="hs-identifier hs-type">emitPrimCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmFormal"><span class="hs-identifier hs-type">CmmFormal</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.MachOp.html#CallishMachOp"><span class="hs-identifier hs-type">CallishMachOp</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmActual"><span class="hs-identifier hs-type">CmmActual</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span id="emitPrimCall"><span class="annot"><span class="annottext">emitPrimCall :: [LocalReg] -&gt; CallishMachOp -&gt; [CmmExpr] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitPrimCall"><span class="hs-identifier hs-var hs-var">emitPrimCall</span></a></span></span><span> </span><span id="local-6989586621681057074"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057074"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span id="local-6989586621681057073"><span class="annot"><span class="annottext">CallishMachOp
</span><a href="#local-6989586621681057073"><span class="hs-identifier hs-var">op</span></a></span></span><span> </span><span id="local-6989586621681057072"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057072"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-208"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FCode ReturnKind -&gt; FCode ()
forall (f :: * -&gt; *) a. Functor f =&gt; f a -&gt; f ()
</span><a href="../../base/src/Data.Functor.html#void"><span class="hs-identifier hs-var">void</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode ReturnKind -&gt; FCode ()) -&gt; FCode ReturnKind -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
-&gt; [LocalReg] -&gt; ForeignTarget -&gt; [CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-var">emitForeignCall</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="GHC.Types.ForeignCall.html#PlayRisky"><span class="hs-identifier hs-var">PlayRisky</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057074"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CallishMachOp -&gt; ForeignTarget
</span><a href="GHC.Cmm.Node.html#PrimTarget"><span class="hs-identifier hs-var">PrimTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CallishMachOp
</span><a href="#local-6989586621681057073"><span class="hs-identifier hs-var">op</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057072"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- alternative entry point, used by GHC.Cmm.Parser</span><span>
</span><span id="line-211"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-type">emitForeignCall</span></a></span><span>
</span><span id="line-212"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#Safety"><span class="hs-identifier hs-type">Safety</span></a></span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmFormal"><span class="hs-identifier hs-type">CmmFormal</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- where to put the results</span><span>
</span><span id="line-214"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-type">ForeignTarget</span></a></span><span>        </span><span class="hs-comment">-- the op</span><span>
</span><span id="line-215"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Node.html#CmmActual"><span class="hs-identifier hs-type">CmmActual</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- arguments</span><span>
</span><span id="line-216"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#ReturnKind"><span class="hs-identifier hs-type">ReturnKind</span></a></span><span>
</span><span id="line-217"></span><span id="emitForeignCall"><span class="annot"><span class="annottext">emitForeignCall :: Safety
-&gt; [LocalReg] -&gt; ForeignTarget -&gt; [CmmExpr] -&gt; FCode ReturnKind
</span><a href="GHC.StgToCmm.Foreign.html#emitForeignCall"><span class="hs-identifier hs-var hs-var">emitForeignCall</span></a></span></span><span> </span><span id="local-6989586621681057070"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057070"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span id="local-6989586621681057069"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057069"><span class="hs-identifier hs-var">results</span></a></span></span><span> </span><span id="local-6989586621681057068"><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057068"><span class="hs-identifier hs-var">target</span></a></span></span><span> </span><span id="local-6989586621681057067"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057067"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-218"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Safety -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#playSafe"><span class="hs-identifier hs-var">playSafe</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057070"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-219"></span><span>    </span><span id="local-6989586621681057064"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057064"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-220"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681057062"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057062"><span class="hs-identifier hs-var">caller_save</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057061"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057061"><span class="hs-identifier hs-var">caller_load</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; (CmmAGraph, CmmAGraph)
</span><a href="GHC.StgToCmm.Utils.html#callerSaveVolatileRegs"><span class="hs-identifier hs-var">callerSaveVolatileRegs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057064"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-221"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057062"><span class="hs-identifier hs-var">caller_save</span></a></span><span>
</span><span id="line-222"></span><span>    </span><span id="local-6989586621681057058"><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057058"><span class="hs-identifier hs-var">target'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignTarget -&gt; FCode ForeignTarget
</span><a href="GHC.StgToCmm.Foreign.html#load_target_into_temp"><span class="hs-identifier hs-var">load_target_into_temp</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057068"><span class="hs-identifier hs-var">target</span></a></span><span>
</span><span id="line-223"></span><span>    </span><span id="local-6989586621681057056"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057056"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; FCode CmmExpr) -&gt; [CmmExpr] -&gt; FCode [CmmExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#maybe_assign_temp"><span class="hs-identifier hs-var">maybe_assign_temp</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057067"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-224"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget -&gt; [LocalReg] -&gt; [CmmExpr] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkUnsafeCall"><span class="hs-identifier hs-var">mkUnsafeCall</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057058"><span class="hs-identifier hs-var">target'</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057069"><span class="hs-identifier hs-var">results</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057056"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-225"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057061"><span class="hs-identifier hs-var">caller_load</span></a></span><span>
</span><span id="line-226"></span><span>    </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#AssignedDirectly"><span class="hs-identifier hs-var">AssignedDirectly</span></a></span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-229"></span><span>    </span><span id="local-6989586621681057051"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057051"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-230"></span><span>    </span><span id="local-6989586621681057050"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057050"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-231"></span><span>    </span><span id="local-6989586621681057049"><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681057049"><span class="hs-identifier hs-var">updfr_off</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode ByteOff
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-232"></span><span>    </span><span id="local-6989586621681057047"><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057047"><span class="hs-identifier hs-var">target'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignTarget -&gt; FCode ForeignTarget
</span><a href="GHC.StgToCmm.Foreign.html#load_target_into_temp"><span class="hs-identifier hs-var">load_target_into_temp</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057068"><span class="hs-identifier hs-var">target</span></a></span><span>
</span><span id="line-233"></span><span>    </span><span id="local-6989586621681057046"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057046"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CmmExpr -&gt; FCode CmmExpr) -&gt; [CmmExpr] -&gt; FCode [CmmExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#maybe_assign_temp"><span class="hs-identifier hs-var">maybe_assign_temp</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057067"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-234"></span><span>    </span><span id="local-6989586621681057045"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-235"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681057044"><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681057044"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681057043"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057043"><span class="hs-identifier hs-var">copyout</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Convention
-&gt; Area
-&gt; [LocalReg]
-&gt; [LocalReg]
-&gt; (ByteOff, [GlobalReg], CmmAGraph)
</span><a href="GHC.Cmm.Graph.html#copyInOflow"><span class="hs-identifier hs-var">copyInOflow</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057051"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeReturn"><span class="hs-identifier hs-var">NativeReturn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Area
</span><a href="GHC.Cmm.Expr.html#Young"><span class="hs-identifier hs-var">Young</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057069"><span class="hs-identifier hs-var">results</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-236"></span><span>       </span><span class="hs-comment">-- see Note [safe foreign call convention]</span><span>
</span><span id="line-237"></span><span>    </span><span id="local-6989586621681057039"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681057039"><span class="hs-identifier hs-var">tscope</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode CmmTickScope
</span><a href="GHC.StgToCmm.Monad.html#getTickScope"><span class="hs-identifier hs-var">getTickScope</span></a></span><span>
</span><span id="line-238"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-239"></span><span>           </span><span class="hs-special">(</span><span>    </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Area -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmStackSlot"><span class="hs-identifier hs-var">CmmStackSlot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Area
</span><a href="GHC.Cmm.Expr.html#Young"><span class="hs-identifier hs-var">Young</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; ByteOff
</span><a href="GHC.Cmm.Type.html#widthInBytes"><span class="hs-identifier hs-var">widthInBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Width
</span><a href="GHC.Cmm.Type.html#wordWidth"><span class="hs-identifier hs-var">wordWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057050"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmBlock"><span class="hs-identifier hs-var">CmmBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-241"></span><span>            </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmNode O C -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkLast"><span class="hs-identifier hs-var">mkLast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmForeignCall :: ForeignTarget
-&gt; [LocalReg]
-&gt; [CmmExpr]
-&gt; BlockId
-&gt; ByteOff
-&gt; ByteOff
-&gt; Bool
-&gt; CmmNode O C
</span><a href="GHC.Cmm.Node.html#CmmForeignCall"><span class="hs-identifier hs-type">CmmForeignCall</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tgt :: ForeignTarget
</span><a href="#local-6989586621681057030"><span class="hs-identifier hs-var">tgt</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057047"><span class="hs-identifier hs-var">target'</span></a></span><span>
</span><span id="line-242"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">res :: [LocalReg]
</span><a href="#local-6989586621681057029"><span class="hs-identifier hs-var">res</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681057069"><span class="hs-identifier hs-var">results</span></a></span><span>
</span><span id="line-243"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">args :: [CmmExpr]
</span><a href="#local-6989586621681057028"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681057046"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-244"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">succ :: BlockId
</span><a href="#local-6989586621681057027"><span class="hs-identifier hs-var">succ</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-245"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ret_args :: ByteOff
</span><a href="#local-6989586621681057026"><span class="hs-identifier hs-var">ret_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681057044"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-246"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ret_off :: ByteOff
</span><a href="#local-6989586621681057025"><span class="hs-identifier hs-var">ret_off</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681057049"><span class="hs-identifier hs-var">updfr_off</span></a></span><span>
</span><span id="line-247"></span><span>                                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">intrbl :: Bool
</span><a href="#local-6989586621681057024"><span class="hs-identifier hs-var">intrbl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Safety -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#playInterruptible"><span class="hs-identifier hs-var">playInterruptible</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681057070"><span class="hs-identifier hs-var">safety</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-248"></span><span>            </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmTickScope -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkLabel"><span class="hs-identifier hs-var">mkLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681057039"><span class="hs-identifier hs-var">tscope</span></a></span><span>
</span><span id="line-249"></span><span>            </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057043"><span class="hs-identifier hs-var">copyout</span></a></span><span>
</span><span id="line-250"></span><span>           </span><span class="hs-special">)</span><span>
</span><span id="line-251"></span><span>    </span><span class="annot"><span class="annottext">ReturnKind -&gt; FCode ReturnKind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; ByteOff -&gt; ReturnKind
</span><a href="GHC.StgToCmm.Monad.html#ReturnedTo"><span class="hs-identifier hs-var">ReturnedTo</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681057045"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681057044"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-252"></span><span>
</span><span id="line-253"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#load_target_into_temp"><span class="hs-identifier hs-type">load_target_into_temp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-type">ForeignTarget</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-type">ForeignTarget</span></a></span><span>
</span><span id="line-254"></span><span id="load_target_into_temp"><span class="annot"><span class="annottext">load_target_into_temp :: ForeignTarget -&gt; FCode ForeignTarget
</span><a href="GHC.StgToCmm.Foreign.html#load_target_into_temp"><span class="hs-identifier hs-var hs-var">load_target_into_temp</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-type">ForeignTarget</span></a></span><span> </span><span id="local-6989586621681057020"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057020"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681057019"><span class="annot"><span class="annottext">ForeignConvention
</span><a href="#local-6989586621681057019"><span class="hs-identifier hs-var">conv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-255"></span><span>  </span><span id="local-6989586621681057018"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057018"><span class="hs-identifier hs-var">tmp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#maybe_assign_temp"><span class="hs-identifier hs-var">maybe_assign_temp</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057020"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-256"></span><span>  </span><span class="annot"><span class="annottext">ForeignTarget -&gt; FCode ForeignTarget
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; ForeignConvention -&gt; ForeignTarget
</span><a href="GHC.Cmm.Node.html#ForeignTarget"><span class="hs-identifier hs-var">ForeignTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057018"><span class="hs-identifier hs-var">tmp</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignConvention
</span><a href="#local-6989586621681057019"><span class="hs-identifier hs-var">conv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#load_target_into_temp"><span class="hs-identifier hs-var">load_target_into_temp</span></a></span><span> </span><span id="local-6989586621681057017"><span class="annot"><span class="annottext">other_target :: ForeignTarget
</span><a href="#local-6989586621681057017"><span class="hs-identifier hs-var">other_target</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Node.html#PrimTarget"><span class="hs-identifier hs-type">PrimTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CallishMachOp
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-258"></span><span>  </span><span class="annot"><span class="annottext">ForeignTarget -&gt; FCode ForeignTarget
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignTarget
</span><a href="#local-6989586621681057017"><span class="hs-identifier hs-var">other_target</span></a></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="hs-comment">-- What we want to do here is create a new temporary for the foreign</span><span>
</span><span id="line-261"></span><span class="hs-comment">-- call argument if it is not safe to use the expression directly,</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- because the expression mentions caller-saves GlobalRegs (see</span><span>
</span><span id="line-263"></span><span class="hs-comment">-- Note [Register parameter passing]).</span><span>
</span><span id="line-264"></span><span class="hs-comment">--</span><span>
</span><span id="line-265"></span><span class="hs-comment">-- However, we can't pattern-match on the expression here, because</span><span>
</span><span id="line-266"></span><span class="hs-comment">-- this is used in a loop by GHC.Cmm.Parser, and testing the expression</span><span>
</span><span id="line-267"></span><span class="hs-comment">-- results in a black hole.  So we always create a temporary, and rely</span><span>
</span><span id="line-268"></span><span class="hs-comment">-- on GHC.Cmm.Sink to clean it up later.  (Yuck, ToDo).  The generated code</span><span>
</span><span id="line-269"></span><span class="hs-comment">-- ends up being the same, at least for the RTS .cmm code.</span><span>
</span><span id="line-270"></span><span class="hs-comment">--</span><span>
</span><span id="line-271"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#maybe_assign_temp"><span class="hs-identifier hs-type">maybe_assign_temp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-272"></span><span id="maybe_assign_temp"><span class="annot"><span class="annottext">maybe_assign_temp :: CmmExpr -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#maybe_assign_temp"><span class="hs-identifier hs-var hs-var">maybe_assign_temp</span></a></span></span><span> </span><span id="local-6989586621681057016"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057016"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-273"></span><span>  </span><span id="local-6989586621681057015"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057015"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-274"></span><span>  </span><span id="local-6989586621681057014"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681057014"><span class="hs-identifier hs-var">reg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; FCode LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmType
</span><a href="GHC.Cmm.Expr.html#cmmExprType"><span class="hs-identifier hs-var">cmmExprType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681057015"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057016"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-275"></span><span>  </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitAssign"><span class="hs-identifier hs-var">emitAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681057014"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681057016"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-276"></span><span>  </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode CmmExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681057014"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-277"></span><span>
</span><span id="line-278"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-279"></span><span class="hs-comment">-- Save/restore the thread state in the TSO</span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span class="hs-comment">-- This stuff can't be done in suspendThread/resumeThread, because it</span><span>
</span><span id="line-282"></span><span class="hs-comment">-- refers to global registers which aren't available in the C world.</span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitSaveThreadState"><span class="hs-identifier hs-type">emitSaveThreadState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-285"></span><span id="emitSaveThreadState"><span class="annot"><span class="annottext">emitSaveThreadState :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitSaveThreadState"><span class="hs-identifier hs-var hs-var">emitSaveThreadState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-286"></span><span>  </span><span id="local-6989586621681057011"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057011"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-287"></span><span>  </span><span id="local-6989586621681057010"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057010"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; FCode CmmAGraph
forall (m :: * -&gt; *). MonadUnique m =&gt; DynFlags -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#saveThreadState"><span class="hs-identifier hs-var">saveThreadState</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681057011"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-288"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681057010"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-289"></span><span>
</span><span id="line-290"></span><span class="hs-comment">-- | Produce code to save the current thread state to @CurrentTSO@</span><span>
</span><span id="line-291"></span><span id="local-6989586621681057280"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#saveThreadState"><span class="hs-identifier hs-type">saveThreadState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#MonadUnique"><span class="hs-identifier hs-type">MonadUnique</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681057280"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681057280"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span></span><span>
</span><span id="line-292"></span><span id="saveThreadState"><span class="annot"><span class="annottext">saveThreadState :: forall (m :: * -&gt; *). MonadUnique m =&gt; DynFlags -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#saveThreadState"><span class="hs-identifier hs-var hs-var">saveThreadState</span></a></span></span><span> </span><span id="local-6989586621681056999"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-293"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056998"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-294"></span><span>  </span><span id="local-6989586621681056996"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056996"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#gcWord"><span class="hs-identifier hs-var">gcWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>  </span><span id="local-6989586621681056994"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056994"><span class="hs-identifier hs-var">close_nursery</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; LocalReg -&gt; m CmmAGraph
forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#closeNursery"><span class="hs-identifier hs-var">closeNursery</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056996"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-296"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; m CmmAGraph
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; m CmmAGraph) -&gt; CmmAGraph -&gt; m CmmAGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-297"></span><span>    </span><span class="hs-comment">-- tso = CurrentTSO;</span><span>
</span><span id="line-298"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056996"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentTSOExpr"><span class="hs-identifier hs-var">currentTSOExpr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-299"></span><span>    </span><span class="hs-comment">-- tso-&gt;stackobj-&gt;sp = Sp;</span><span>
</span><span id="line-300"></span><span>    </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-301"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-302"></span><span>                                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056996"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-303"></span><span>                                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_stackobj"><span class="hs-identifier hs-var">tso_stackobj</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-304"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#stack_SP"><span class="hs-identifier hs-var">stack_SP</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-306"></span><span>            </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#spExpr"><span class="hs-identifier hs-var">spExpr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-307"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056994"><span class="hs-identifier hs-var">close_nursery</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-308"></span><span>    </span><span class="hs-comment">-- and save the current cost centre stack in the TSO when profiling:</span><span>
</span><span id="line-309"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#sccProfilingEnabled"><span class="hs-identifier hs-var">sccProfilingEnabled</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-310"></span><span>        </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056998"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056996"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_CCCS"><span class="hs-identifier hs-var">tso_CCCS</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056999"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#cccsExpr"><span class="hs-identifier hs-var">cccsExpr</span></a></span><span>
</span><span id="line-311"></span><span>      </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkNop"><span class="hs-identifier hs-var">mkNop</span></a></span><span>
</span><span id="line-312"></span><span>    </span><span class="hs-special">]</span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span class="hs-comment">-- | Save STG registers</span><span>
</span><span id="line-317"></span><span class="hs-comment">--</span><span>
</span><span id="line-318"></span><span class="hs-comment">-- STG registers must be saved around a C call, just in case the STG</span><span>
</span><span id="line-319"></span><span class="hs-comment">-- register is mapped to a caller-saves machine register.  Normally we</span><span>
</span><span id="line-320"></span><span class="hs-comment">-- don't need to worry about this the code generator has already</span><span>
</span><span id="line-321"></span><span class="hs-comment">-- loaded any live STG registers into variables for us, but in</span><span>
</span><span id="line-322"></span><span class="hs-comment">-- hand-written low-level Cmm code where we don't know which registers</span><span>
</span><span id="line-323"></span><span class="hs-comment">-- are live, we might have to save them all.</span><span>
</span><span id="line-324"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitSaveRegs"><span class="hs-identifier hs-type">emitSaveRegs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-325"></span><span id="emitSaveRegs"><span class="annot"><span class="annottext">emitSaveRegs :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitSaveRegs"><span class="hs-identifier hs-var hs-var">emitSaveRegs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-326"></span><span>   </span><span id="local-6989586621681056979"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056979"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-327"></span><span>   </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056978"><span class="annot"><span class="annottext">regs :: [GlobalReg]
</span><a href="#local-6989586621681056978"><span class="hs-identifier hs-var hs-var">regs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [GlobalReg]
</span><a href="GHC.Cmm.CallConv.html#realArgRegsCover"><span class="hs-identifier hs-var">realArgRegsCover</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056979"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-328"></span><span>       </span><span id="local-6989586621681056976"><span class="annot"><span class="annottext">save :: CmmAGraph
</span><a href="#local-6989586621681056976"><span class="hs-identifier hs-var hs-var">save</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalReg -&gt; CmmAGraph) -&gt; [GlobalReg] -&gt; [CmmAGraph]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; GlobalReg -&gt; CmmAGraph
</span><a href="GHC.StgToCmm.Utils.html#callerSaveGlobalReg"><span class="hs-identifier hs-var">callerSaveGlobalReg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056979"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681056978"><span class="hs-identifier hs-var">regs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>   </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056976"><span class="hs-identifier hs-var">save</span></a></span><span>
</span><span id="line-330"></span><span>
</span><span id="line-331"></span><span class="hs-comment">-- | Restore STG registers (see 'emitSaveRegs')</span><span>
</span><span id="line-332"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitRestoreRegs"><span class="hs-identifier hs-type">emitRestoreRegs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-333"></span><span id="emitRestoreRegs"><span class="annot"><span class="annottext">emitRestoreRegs :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitRestoreRegs"><span class="hs-identifier hs-var hs-var">emitRestoreRegs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-334"></span><span>   </span><span id="local-6989586621681056974"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056974"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-335"></span><span>   </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056973"><span class="annot"><span class="annottext">regs :: [GlobalReg]
</span><a href="#local-6989586621681056973"><span class="hs-identifier hs-var hs-var">regs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; [GlobalReg]
</span><a href="GHC.Cmm.CallConv.html#realArgRegsCover"><span class="hs-identifier hs-var">realArgRegsCover</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056974"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-336"></span><span>       </span><span id="local-6989586621681056972"><span class="annot"><span class="annottext">save :: CmmAGraph
</span><a href="#local-6989586621681056972"><span class="hs-identifier hs-var hs-var">save</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(GlobalReg -&gt; CmmAGraph) -&gt; [GlobalReg] -&gt; [CmmAGraph]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; GlobalReg -&gt; CmmAGraph
</span><a href="GHC.StgToCmm.Utils.html#callerRestoreGlobalReg"><span class="hs-identifier hs-var">callerRestoreGlobalReg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056974"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681056973"><span class="hs-identifier hs-var">regs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span>   </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056972"><span class="hs-identifier hs-var">save</span></a></span><span>
</span><span id="line-338"></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitCloseNursery"><span class="hs-identifier hs-type">emitCloseNursery</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span id="emitCloseNursery"><span class="annot"><span class="annottext">emitCloseNursery :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitCloseNursery"><span class="hs-identifier hs-var hs-var">emitCloseNursery</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-342"></span><span>  </span><span id="local-6989586621681056970"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056970"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-343"></span><span>  </span><span id="local-6989586621681056969"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056969"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-344"></span><span>  </span><span id="local-6989586621681056968"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056968"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; FCode LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056969"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-345"></span><span>  </span><span id="local-6989586621681056967"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056967"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; LocalReg -&gt; FCode CmmAGraph
forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#closeNursery"><span class="hs-identifier hs-var">closeNursery</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056970"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056968"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-346"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056968"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentTSOExpr"><span class="hs-identifier hs-var">currentTSOExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056967"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="hs-comment">{- |
@closeNursery dflags tso@ produces code to close the nursery.
A local register holding the value of @CurrentTSO@ is expected for
efficiency.

Closing the nursery corresponds to the following code:

@
  tso = CurrentTSO;
  cn = CurrentNuresry;

  // Update the allocation limit for the current thread.  We don't
  // check to see whether it has overflowed at this point, that check is
  // made when we run out of space in the current heap block (stg_gc_noregs)
  // and in the scheduler when context switching (schedulePostRunThread).
  tso-&gt;alloc_limit -= Hp + WDS(1) - cn-&gt;start;

  // Set cn-&gt;free to the next unoccupied word in the block
  cn-&gt;free = Hp + WDS(1);
@
-}</span><span>
</span><span id="line-369"></span><span id="local-6989586621681057277"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#closeNursery"><span class="hs-identifier hs-type">closeNursery</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#MonadUnique"><span class="hs-identifier hs-type">MonadUnique</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681057277"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681057277"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span></span><span>
</span><span id="line-370"></span><span id="closeNursery"><span class="annot"><span class="annottext">closeNursery :: forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#closeNursery"><span class="hs-identifier hs-var hs-var">closeNursery</span></a></span></span><span> </span><span id="local-6989586621681056957"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056957"><span class="hs-identifier hs-var">df</span></a></span></span><span> </span><span id="local-6989586621681056956"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056956"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-371"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056955"><span class="annot"><span class="annottext">tsoreg :: CmmReg
</span><a href="#local-6989586621681056955"><span class="hs-identifier hs-var hs-var">tsoreg</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056956"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-372"></span><span>      </span><span id="local-6989586621681056954"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056957"><span class="hs-identifier hs-var">df</span></a></span><span>
</span><span id="line-373"></span><span>  </span><span id="local-6989586621681056953"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056953"><span class="hs-identifier hs-var">cnreg</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmReg) -&gt; m LocalReg -&gt; m CmmReg
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-374"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; m CmmAGraph
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; m CmmAGraph) -&gt; CmmAGraph -&gt; m CmmAGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-375"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056953"><span class="hs-identifier hs-var">cnreg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentNurseryExpr"><span class="hs-identifier hs-var">currentNurseryExpr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-376"></span><span>
</span><span id="line-377"></span><span>    </span><span class="hs-comment">-- CurrentNursery-&gt;free = Hp+1;</span><span>
</span><span id="line-378"></span><span>    </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_free"><span class="hs-identifier hs-var">nursery_bdescr_free</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056957"><span class="hs-identifier hs-var">df</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056953"><span class="hs-identifier hs-var">cnreg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetW"><span class="hs-identifier hs-var">cmmOffsetW</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#hpExpr"><span class="hs-identifier hs-var">hpExpr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056947"><span class="annot"><span class="annottext">alloc :: CmmExpr
</span><a href="#local-6989586621681056947"><span class="hs-identifier hs-var hs-var">alloc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-381"></span><span>           </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordSub"><span class="hs-identifier hs-var">mo_wordSub</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span>              </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetW"><span class="hs-identifier hs-var">cmmOffsetW</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#hpExpr"><span class="hs-identifier hs-var">hpExpr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><span class="hs-number">1</span></span><span>
</span><span id="line-383"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_start"><span class="hs-identifier hs-var">nursery_bdescr_start</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056957"><span class="hs-identifier hs-var">df</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056953"><span class="hs-identifier hs-var">cnreg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-384"></span><span>              </span><span class="hs-special">]</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span>        </span><span id="local-6989586621681056943"><span class="annot"><span class="annottext">alloc_limit :: CmmExpr
</span><a href="#local-6989586621681056943"><span class="hs-identifier hs-var hs-var">alloc_limit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056955"><span class="hs-identifier hs-var">tsoreg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_alloc_limit"><span class="hs-identifier hs-var">tso_alloc_limit</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056957"><span class="hs-identifier hs-var">df</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-387"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-388"></span><span>
</span><span id="line-389"></span><span>    </span><span class="hs-comment">-- tso-&gt;alloc_limit += alloc</span><span>
</span><span id="line-390"></span><span>    </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056943"><span class="hs-identifier hs-var">alloc_limit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#MO_Sub"><span class="hs-identifier hs-var">MO_Sub</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W64"><span class="hs-identifier hs-var">W64</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span>                               </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056943"><span class="hs-identifier hs-var">alloc_limit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="GHC.Cmm.Type.html#b64"><span class="hs-identifier hs-var">b64</span></a></span><span>
</span><span id="line-392"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_WordTo64"><span class="hs-identifier hs-var">mo_WordTo64</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056954"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056947"><span class="hs-identifier hs-var">alloc</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>   </span><span class="hs-special">]</span><span>
</span><span id="line-394"></span><span>
</span><span id="line-395"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitLoadThreadState"><span class="hs-identifier hs-type">emitLoadThreadState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span id="emitLoadThreadState"><span class="annot"><span class="annottext">emitLoadThreadState :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitLoadThreadState"><span class="hs-identifier hs-var hs-var">emitLoadThreadState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-397"></span><span>  </span><span id="local-6989586621681056937"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056937"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-398"></span><span>  </span><span id="local-6989586621681056936"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056936"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; FCode CmmAGraph
forall (m :: * -&gt; *). MonadUnique m =&gt; DynFlags -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#loadThreadState"><span class="hs-identifier hs-var">loadThreadState</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056937"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-399"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056936"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-400"></span><span>
</span><span id="line-401"></span><span class="hs-comment">-- | Produce code to load the current thread state from @CurrentTSO@</span><span>
</span><span id="line-402"></span><span id="local-6989586621681056935"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#loadThreadState"><span class="hs-identifier hs-type">loadThreadState</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#MonadUnique"><span class="hs-identifier hs-type">MonadUnique</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681056935"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681056935"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span></span><span>
</span><span id="line-403"></span><span id="loadThreadState"><span class="annot"><span class="annottext">loadThreadState :: forall (m :: * -&gt; *). MonadUnique m =&gt; DynFlags -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#loadThreadState"><span class="hs-identifier hs-var hs-var">loadThreadState</span></a></span></span><span> </span><span id="local-6989586621681056924"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-404"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056923"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-405"></span><span>  </span><span id="local-6989586621681056922"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056922"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#gcWord"><span class="hs-identifier hs-var">gcWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-406"></span><span>  </span><span id="local-6989586621681056921"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056921"><span class="hs-identifier hs-var">stack</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#gcWord"><span class="hs-identifier hs-var">gcWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>  </span><span id="local-6989586621681056920"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056920"><span class="hs-identifier hs-var">open_nursery</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; LocalReg -&gt; m CmmAGraph
forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#openNursery"><span class="hs-identifier hs-var">openNursery</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056922"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-408"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; m CmmAGraph
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; m CmmAGraph) -&gt; CmmAGraph -&gt; m CmmAGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-409"></span><span>    </span><span class="hs-comment">-- tso = CurrentTSO;</span><span>
</span><span id="line-410"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056922"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentTSOExpr"><span class="hs-identifier hs-var">currentTSOExpr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-411"></span><span>    </span><span class="hs-comment">-- stack = tso-&gt;stackobj;</span><span>
</span><span id="line-412"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056921"><span class="hs-identifier hs-var">stack</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056922"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_stackobj"><span class="hs-identifier hs-var">tso_stackobj</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-413"></span><span>    </span><span class="hs-comment">-- Sp = stack-&gt;sp;</span><span>
</span><span id="line-414"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#spReg"><span class="hs-identifier hs-var">spReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056921"><span class="hs-identifier hs-var">stack</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#stack_SP"><span class="hs-identifier hs-var">stack_SP</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-415"></span><span>    </span><span class="hs-comment">-- SpLim = stack-&gt;stack + RESERVED_STACK_WORDS;</span><span>
</span><span id="line-416"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#spLimReg"><span class="hs-identifier hs-var">spLimReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetW"><span class="hs-identifier hs-var">cmmOffsetW</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056921"><span class="hs-identifier hs-var">stack</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#stack_STACK"><span class="hs-identifier hs-var">stack_STACK</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#rESERVED_STACK_WORDS"><span class="hs-identifier hs-var">rESERVED_STACK_WORDS</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-418"></span><span>    </span><span class="hs-comment">-- HpAlloc = 0;</span><span>
</span><span id="line-419"></span><span>    </span><span class="hs-comment">--   HpAlloc is assumed to be set to non-zero only by a failed</span><span>
</span><span id="line-420"></span><span>    </span><span class="hs-comment">--   a heap check, see HeapStackCheck.cmm:GC_GENERIC</span><span>
</span><span id="line-421"></span><span>    </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpAllocReg"><span class="hs-identifier hs-var">hpAllocReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#zeroExpr"><span class="hs-identifier hs-var">zeroExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-422"></span><span>    </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056920"><span class="hs-identifier hs-var">open_nursery</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-423"></span><span>    </span><span class="hs-comment">-- and load the current cost centre stack from the TSO when profiling:</span><span>
</span><span id="line-424"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#sccProfilingEnabled"><span class="hs-identifier hs-var">sccProfilingEnabled</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-425"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmAGraph
</span><a href="GHC.StgToCmm.Prof.html#storeCurCCS"><span class="hs-identifier hs-var">storeCurCCS</span></a></span><span>
</span><span id="line-426"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056922"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-427"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_CCCS"><span class="hs-identifier hs-var">tso_CCCS</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056924"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.StgToCmm.Prof.html#ccsType"><span class="hs-identifier hs-var">ccsType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056923"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-428"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkNop"><span class="hs-identifier hs-var">mkNop</span></a></span><span>
</span><span id="line-429"></span><span>   </span><span class="hs-special">]</span><span>
</span><span id="line-430"></span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#emitOpenNursery"><span class="hs-identifier hs-type">emitOpenNursery</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-433"></span><span id="emitOpenNursery"><span class="annot"><span class="annottext">emitOpenNursery :: FCode ()
</span><a href="GHC.StgToCmm.Foreign.html#emitOpenNursery"><span class="hs-identifier hs-var hs-var">emitOpenNursery</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-434"></span><span>  </span><span id="local-6989586621681056912"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056912"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-435"></span><span>  </span><span id="local-6989586621681056911"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056911"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-436"></span><span>  </span><span id="local-6989586621681056910"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056910"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; FCode LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056911"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-437"></span><span>  </span><span id="local-6989586621681056909"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056909"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; LocalReg -&gt; FCode CmmAGraph
forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#openNursery"><span class="hs-identifier hs-var">openNursery</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056912"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056910"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-438"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; CmmAGraph -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056910"><span class="hs-identifier hs-var">tso</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentTSOExpr"><span class="hs-identifier hs-var">currentTSOExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681056909"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="hs-comment">{- |
@openNursery dflags tso@ produces code to open the nursery. A local register
holding the value of @CurrentTSO@ is expected for efficiency.

Opening the nursery corresponds to the following code:

@
   tso = CurrentTSO;
   cn = CurrentNursery;
   bdfree = CurrentNursery-&gt;free;
   bdstart = CurrentNursery-&gt;start;

   // We *add* the currently occupied portion of the nursery block to
   // the allocation limit, because we will subtract it again in
   // closeNursery.
   tso-&gt;alloc_limit += bdfree - bdstart;

   // Set Hp to the last occupied word of the heap block.  Why not the
   // next unocupied word?  Doing it this way means that we get to use
   // an offset of zero more often, which might lead to slightly smaller
   // code on some architectures.
   Hp = bdfree - WDS(1);

   // Set HpLim to the end of the current nursery block (note that this block
   // might be a block group, consisting of several adjacent blocks.
   HpLim = bdstart + CurrentNursery-&gt;blocks*BLOCK_SIZE_W - 1;
@
-}</span><span>
</span><span id="line-468"></span><span id="local-6989586621681056908"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#openNursery"><span class="hs-identifier hs-type">openNursery</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html#MonadUnique"><span class="hs-identifier hs-type">MonadUnique</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681056908"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681056908"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span></span><span>
</span><span id="line-469"></span><span id="openNursery"><span class="annot"><span class="annottext">openNursery :: forall (m :: * -&gt; *).
MonadUnique m =&gt;
DynFlags -&gt; LocalReg -&gt; m CmmAGraph
</span><a href="GHC.StgToCmm.Foreign.html#openNursery"><span class="hs-identifier hs-var hs-var">openNursery</span></a></span></span><span> </span><span id="local-6989586621681056889"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056888"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056888"><span class="hs-identifier hs-var">tso</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-470"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056887"><span class="annot"><span class="annottext">tsoreg :: CmmReg
</span><a href="#local-6989586621681056887"><span class="hs-identifier hs-var hs-var">tsoreg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681056888"><span class="hs-identifier hs-var">tso</span></a></span><span>
</span><span id="line-471"></span><span>      </span><span id="local-6989586621681056886"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-472"></span><span>  </span><span id="local-6989586621681056885"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056885"><span class="hs-identifier hs-var">cnreg</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmReg) -&gt; m LocalReg -&gt; m CmmReg
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>  </span><span id="local-6989586621681056884"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056884"><span class="hs-identifier hs-var">bdfreereg</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmReg) -&gt; m LocalReg -&gt; m CmmReg
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>  </span><span id="local-6989586621681056883"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056883"><span class="hs-identifier hs-var">bdstartreg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmReg) -&gt; m LocalReg -&gt; m CmmReg
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; m LocalReg
forall (m :: * -&gt; *). MonadUnique m =&gt; CmmType -&gt; m LocalReg
</span><a href="GHC.StgToCmm.Utils.html#newTemp"><span class="hs-identifier hs-var">newTemp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>
</span><span id="line-476"></span><span>  </span><span class="hs-comment">-- These assignments are carefully ordered to reduce register</span><span>
</span><span id="line-477"></span><span>  </span><span class="hs-comment">-- pressure and generate not completely awful code on x86.  To see</span><span>
</span><span id="line-478"></span><span>  </span><span class="hs-comment">-- what code we generate, look at the assembly for</span><span>
</span><span id="line-479"></span><span>  </span><span class="hs-comment">-- stg_returnToStackTop in rts/StgStartup.cmm.</span><span>
</span><span id="line-480"></span><span>  </span><span class="annot"><span class="annottext">CmmAGraph -&gt; m CmmAGraph
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; m CmmAGraph) -&gt; CmmAGraph -&gt; m CmmAGraph
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmAGraph] -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#catAGraphs"><span class="hs-identifier hs-var">catAGraphs</span></a></span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-481"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056885"><span class="hs-identifier hs-var">cnreg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#currentNurseryExpr"><span class="hs-identifier hs-var">currentNurseryExpr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-482"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056884"><span class="hs-identifier hs-var">bdfreereg</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_free"><span class="hs-identifier hs-var">nursery_bdescr_free</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056885"><span class="hs-identifier hs-var">cnreg</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span>     </span><span class="hs-comment">-- Hp = CurrentNursery-&gt;free - 1;</span><span>
</span><span id="line-485"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpReg"><span class="hs-identifier hs-var">hpReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetW"><span class="hs-identifier hs-var">cmmOffsetW</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056884"><span class="hs-identifier hs-var">bdfreereg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">ByteOff
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-486"></span><span>
</span><span id="line-487"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056883"><span class="hs-identifier hs-var">bdstartreg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_start"><span class="hs-identifier hs-var">nursery_bdescr_start</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056885"><span class="hs-identifier hs-var">cnreg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmType
</span><a href="GHC.Cmm.Type.html#bWord"><span class="hs-identifier hs-var">bWord</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-488"></span><span>
</span><span id="line-489"></span><span>     </span><span class="hs-comment">-- HpLim = CurrentNursery-&gt;start +</span><span>
</span><span id="line-490"></span><span>     </span><span class="hs-comment">--              CurrentNursery-&gt;blocks*BLOCK_SIZE_W - 1;</span><span>
</span><span id="line-491"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpLimReg"><span class="hs-identifier hs-var">hpLimReg</span></a></span><span>
</span><span id="line-492"></span><span>         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetExpr"><span class="hs-identifier hs-var">cmmOffsetExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-493"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056883"><span class="hs-identifier hs-var">bdstartreg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-494"></span><span>             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span>
</span><span id="line-495"></span><span>               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordMul"><span class="hs-identifier hs-var">mo_wordMul</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span>
</span><span id="line-496"></span><span>                 </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; Width -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#MO_SS_Conv"><span class="hs-identifier hs-var">MO_SS_Conv</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W32"><span class="hs-identifier hs-var">W32</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Width
</span><a href="GHC.Cmm.Type.html#wordWidth"><span class="hs-identifier hs-var">wordWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>                   </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_blocks"><span class="hs-identifier hs-var">nursery_bdescr_blocks</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056885"><span class="hs-identifier hs-var">cnreg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="GHC.Cmm.Type.html#b32"><span class="hs-identifier hs-var">b32</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>
</span><span id="line-498"></span><span>                 </span><span class="annot"><span class="annottext">Platform -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#mkIntExpr"><span class="hs-identifier hs-var">mkIntExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#bLOCK_SIZE"><span class="hs-identifier hs-var">bLOCK_SIZE</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-499"></span><span>                </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>               </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">ByteOff
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-501"></span><span>             </span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>         </span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-503"></span><span>
</span><span id="line-504"></span><span>     </span><span class="hs-comment">-- alloc = bd-&gt;free - bd-&gt;start</span><span>
</span><span id="line-505"></span><span>     </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681056872"><span class="annot"><span class="annottext">alloc :: CmmExpr
</span><a href="#local-6989586621681056872"><span class="hs-identifier hs-var hs-var">alloc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-506"></span><span>           </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordSub"><span class="hs-identifier hs-var">mo_wordSub</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056884"><span class="hs-identifier hs-var">bdfreereg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056883"><span class="hs-identifier hs-var">bdstartreg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-507"></span><span>
</span><span id="line-508"></span><span>         </span><span id="local-6989586621681056871"><span class="annot"><span class="annottext">alloc_limit :: CmmExpr
</span><a href="#local-6989586621681056871"><span class="hs-identifier hs-var hs-var">alloc_limit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056887"><span class="hs-identifier hs-var">tsoreg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_alloc_limit"><span class="hs-identifier hs-var">tso_alloc_limit</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056889"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span>     </span><span class="hs-keyword">in</span><span>
</span><span id="line-510"></span><span>
</span><span id="line-511"></span><span>     </span><span class="hs-comment">-- tso-&gt;alloc_limit += alloc</span><span>
</span><span id="line-512"></span><span>     </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkStore"><span class="hs-identifier hs-var">mkStore</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056871"><span class="hs-identifier hs-var">alloc_limit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#MO_Add"><span class="hs-identifier hs-var">MO_Add</span></a></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W64"><span class="hs-identifier hs-var">W64</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-513"></span><span>                               </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmType -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLoad"><span class="hs-identifier hs-var">CmmLoad</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056871"><span class="hs-identifier hs-var">alloc_limit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="GHC.Cmm.Type.html#b64"><span class="hs-identifier hs-var">b64</span></a></span><span>
</span><span id="line-514"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_WordTo64"><span class="hs-identifier hs-var">mo_WordTo64</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056886"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056872"><span class="hs-identifier hs-var">alloc</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span>
</span><span id="line-516"></span><span>   </span><span class="hs-special">]</span><span>
</span><span id="line-517"></span><span>
</span><span id="line-518"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_free"><span class="hs-identifier hs-type">nursery_bdescr_free</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_start"><span class="hs-identifier hs-type">nursery_bdescr_start</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_blocks"><span class="hs-identifier hs-type">nursery_bdescr_blocks</span></a></span><span>
</span><span id="line-519"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-type">CmmReg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-520"></span><span id="nursery_bdescr_free"><span class="annot"><span class="annottext">nursery_bdescr_free :: DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_free"><span class="hs-identifier hs-var hs-var">nursery_bdescr_free</span></a></span></span><span>   </span><span id="local-6989586621681056869"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056869"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056868"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056868"><span class="hs-identifier hs-var">cn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-521"></span><span>  </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056869"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056868"><span class="hs-identifier hs-var">cn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_bdescr_free"><span class="hs-identifier hs-var">oFFSET_bdescr_free</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056869"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-522"></span><span id="nursery_bdescr_start"><span class="annot"><span class="annottext">nursery_bdescr_start :: DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_start"><span class="hs-identifier hs-var hs-var">nursery_bdescr_start</span></a></span></span><span>  </span><span id="local-6989586621681056866"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056866"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056865"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056865"><span class="hs-identifier hs-var">cn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-523"></span><span>  </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056866"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056865"><span class="hs-identifier hs-var">cn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_bdescr_start"><span class="hs-identifier hs-var">oFFSET_bdescr_start</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056866"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-524"></span><span id="nursery_bdescr_blocks"><span class="annot"><span class="annottext">nursery_bdescr_blocks :: DynFlags -&gt; CmmReg -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#nursery_bdescr_blocks"><span class="hs-identifier hs-var hs-var">nursery_bdescr_blocks</span></a></span></span><span> </span><span id="local-6989586621681056863"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056863"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056862"><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056862"><span class="hs-identifier hs-var">cn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-525"></span><span>  </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffset"><span class="hs-identifier hs-var">cmmOffset</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056863"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="#local-6989586621681056862"><span class="hs-identifier hs-var">cn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_bdescr_blocks"><span class="hs-identifier hs-var">oFFSET_bdescr_blocks</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056863"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#tso_stackobj"><span class="hs-identifier hs-type">tso_stackobj</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#tso_CCCS"><span class="hs-identifier hs-type">tso_CCCS</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#tso_alloc_limit"><span class="hs-identifier hs-type">tso_alloc_limit</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#stack_STACK"><span class="hs-identifier hs-type">stack_STACK</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#stack_SP"><span class="hs-identifier hs-type">stack_SP</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span>
</span><span id="line-528"></span><span id="tso_stackobj"><span class="annot"><span class="annottext">tso_stackobj :: DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_stackobj"><span class="hs-identifier hs-var hs-var">tso_stackobj</span></a></span></span><span> </span><span id="local-6989586621681056860"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056860"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var">closureField</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056860"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_StgTSO_stackobj"><span class="hs-identifier hs-var">oFFSET_StgTSO_stackobj</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056860"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span id="tso_alloc_limit"><span class="annot"><span class="annottext">tso_alloc_limit :: DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_alloc_limit"><span class="hs-identifier hs-var hs-var">tso_alloc_limit</span></a></span></span><span> </span><span id="local-6989586621681056857"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056857"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var">closureField</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056857"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_StgTSO_alloc_limit"><span class="hs-identifier hs-var">oFFSET_StgTSO_alloc_limit</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056857"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-530"></span><span id="tso_CCCS"><span class="annot"><span class="annottext">tso_CCCS :: DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#tso_CCCS"><span class="hs-identifier hs-var hs-var">tso_CCCS</span></a></span></span><span>     </span><span id="local-6989586621681056855"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056855"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var">closureField</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056855"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_StgTSO_cccs"><span class="hs-identifier hs-var">oFFSET_StgTSO_cccs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056855"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-531"></span><span id="stack_STACK"><span class="annot"><span class="annottext">stack_STACK :: DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#stack_STACK"><span class="hs-identifier hs-var hs-var">stack_STACK</span></a></span></span><span>  </span><span id="local-6989586621681056853"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056853"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var">closureField</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056853"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_StgStack_stack"><span class="hs-identifier hs-var">oFFSET_StgStack_stack</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056853"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-532"></span><span id="stack_SP"><span class="annot"><span class="annottext">stack_SP :: DynFlags -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#stack_SP"><span class="hs-identifier hs-var hs-var">stack_SP</span></a></span></span><span>     </span><span id="local-6989586621681056851"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056851"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var">closureField</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056851"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Driver.Session.html#oFFSET_StgStack_sp"><span class="hs-identifier hs-var">oFFSET_StgStack_sp</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056851"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-533"></span><span>
</span><span id="line-534"></span><span>
</span><span id="line-535"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-type">closureField</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span>
</span><span id="line-536"></span><span id="closureField"><span class="annot"><span class="annottext">closureField :: DynFlags -&gt; ByteOff -&gt; ByteOff
</span><a href="GHC.StgToCmm.Foreign.html#closureField"><span class="hs-identifier hs-var hs-var">closureField</span></a></span></span><span> </span><span id="local-6989586621681056849"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056849"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056848"><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681056848"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteOff
</span><a href="#local-6989586621681056848"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">ByteOff -&gt; ByteOff -&gt; ByteOff
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Runtime.Heap.Layout.html#fixedHdrSize"><span class="hs-identifier hs-var">fixedHdrSize</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056849"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-537"></span><span>
</span><span id="line-538"></span><span class="hs-comment">-- Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-540"></span><span class="hs-comment">--</span><span>
</span><span id="line-541"></span><span class="hs-comment">-- For certain types passed to foreign calls, we adjust the actual</span><span>
</span><span id="line-542"></span><span class="hs-comment">-- value passed to the call.  For ByteArray#, Array#, SmallArray#,</span><span>
</span><span id="line-543"></span><span class="hs-comment">-- and ArrayArray#, we pass the address of the array's payload, not</span><span>
</span><span id="line-544"></span><span class="hs-comment">-- the address of the heap object. For example, consider</span><span>
</span><span id="line-545"></span><span class="hs-comment">--   foreign import &quot;c_foo&quot; foo :: ByteArray# -&gt; Int# -&gt; IO ()</span><span>
</span><span id="line-546"></span><span class="hs-comment">-- At a Haskell call like `foo x y`, we'll generate a C call that</span><span>
</span><span id="line-547"></span><span class="hs-comment">-- is more like</span><span>
</span><span id="line-548"></span><span class="hs-comment">--   c_foo( x+8, y )</span><span>
</span><span id="line-549"></span><span class="hs-comment">-- where the &quot;+8&quot; takes the heap pointer (x :: ByteArray#) and moves</span><span>
</span><span id="line-550"></span><span class="hs-comment">-- it past the header words of the ByteArray object to point directly</span><span>
</span><span id="line-551"></span><span class="hs-comment">-- to the data inside the ByteArray#. (The exact offset depends</span><span>
</span><span id="line-552"></span><span class="hs-comment">-- on the target architecture and on profiling) By contrast, (y :: Int#)</span><span>
</span><span id="line-553"></span><span class="hs-comment">-- requires no such adjustment.</span><span>
</span><span id="line-554"></span><span class="hs-comment">--</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- This adjustment is performed by 'add_shim'. The size of the</span><span>
</span><span id="line-556"></span><span class="hs-comment">-- adjustment depends on the type of heap object. But</span><span>
</span><span id="line-557"></span><span class="hs-comment">-- how can we determine that type? There are two available options.</span><span>
</span><span id="line-558"></span><span class="hs-comment">-- We could use the types of the actual values that the foreign call</span><span>
</span><span id="line-559"></span><span class="hs-comment">-- has been applied to, or we could use the types present in the</span><span>
</span><span id="line-560"></span><span class="hs-comment">-- foreign function's type. Prior to GHC 8.10, we used the former</span><span>
</span><span id="line-561"></span><span class="hs-comment">-- strategy since it's a little more simple. However, in issue #16650</span><span>
</span><span id="line-562"></span><span class="hs-comment">-- and more compellingly in the comments of</span><span>
</span><span id="line-563"></span><span class="hs-comment">-- https://gitlab.haskell.org/ghc/ghc/merge_requests/939, it was</span><span>
</span><span id="line-564"></span><span class="hs-comment">-- demonstrated that this leads to bad behavior in the presence</span><span>
</span><span id="line-565"></span><span class="hs-comment">-- of unsafeCoerce#. Returning to the above example, suppose the</span><span>
</span><span id="line-566"></span><span class="hs-comment">-- Haskell call looked like</span><span>
</span><span id="line-567"></span><span class="hs-comment">--   foo (unsafeCoerce# p)</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- where the types of expressions comprising the arguments are</span><span>
</span><span id="line-569"></span><span class="hs-comment">--   p :: (Any :: TYPE 'UnliftedRep)</span><span>
</span><span id="line-570"></span><span class="hs-comment">--   i :: Int#</span><span>
</span><span id="line-571"></span><span class="hs-comment">-- so that the unsafe-coerce is between Any and ByteArray#.</span><span>
</span><span id="line-572"></span><span class="hs-comment">-- These two types have the same kind (they are both represented by</span><span>
</span><span id="line-573"></span><span class="hs-comment">-- a heap pointer) so no GC errors will occur if we do this unsafe coerce.</span><span>
</span><span id="line-574"></span><span class="hs-comment">-- By the time this gets to the code generator the cast has been</span><span>
</span><span id="line-575"></span><span class="hs-comment">-- discarded so we have</span><span>
</span><span id="line-576"></span><span class="hs-comment">--   foo p y</span><span>
</span><span id="line-577"></span><span class="hs-comment">-- But we *must* adjust the pointer to p by a ByteArray# shim,</span><span>
</span><span id="line-578"></span><span class="hs-comment">-- *not* by an Any shim (the Any shim involves no offset at all).</span><span>
</span><span id="line-579"></span><span class="hs-comment">--</span><span>
</span><span id="line-580"></span><span class="hs-comment">-- To avoid this bad behavior, we adopt the second strategy: use</span><span>
</span><span id="line-581"></span><span class="hs-comment">-- the types present in the foreign function's type.</span><span>
</span><span id="line-582"></span><span class="hs-comment">-- In collectStgFArgTypes, we convert the foreign function's</span><span>
</span><span id="line-583"></span><span class="hs-comment">-- type to a list of StgFArgType. Then, in add_shim, we interpret</span><span>
</span><span id="line-584"></span><span class="hs-comment">-- these as numeric offsets.</span><span>
</span><span id="line-585"></span><span>
</span><span id="line-586"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#getFCallArgs"><span class="hs-identifier hs-type">getFCallArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-587"></span><span>     </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-588"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-comment">-- the type of the foreign function</span><span>
</span><span id="line-589"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Cmm.Type.html#ForeignHint"><span class="hs-identifier hs-type">ForeignHint</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-590"></span><span class="hs-comment">-- (a) Drop void args</span><span>
</span><span id="line-591"></span><span class="hs-comment">-- (b) Add foreign-call shim code</span><span>
</span><span id="line-592"></span><span class="hs-comment">-- It's (b) that makes this differ from getNonVoidArgAmodes</span><span>
</span><span id="line-593"></span><span class="hs-comment">-- Precondition: args and typs have the same length</span><span>
</span><span id="line-594"></span><span class="hs-comment">-- See Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-595"></span><span id="getFCallArgs"><span class="annot"><span class="annottext">getFCallArgs :: [StgArg] -&gt; Type -&gt; FCode [(CmmExpr, ForeignHint)]
</span><a href="GHC.StgToCmm.Foreign.html#getFCallArgs"><span class="hs-identifier hs-var hs-var">getFCallArgs</span></a></span></span><span> </span><span id="local-6989586621681056845"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681056845"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681056844"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056844"><span class="hs-identifier hs-var">typ</span></a></span></span><span>
</span><span id="line-596"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681056843"><span class="annot"><span class="annottext">[Maybe (CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681056843"><span class="hs-identifier hs-var">mb_cmms</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((StgArg, StgFArgType) -&gt; FCode (Maybe (CmmExpr, ForeignHint)))
-&gt; [(StgArg, StgFArgType)] -&gt; FCode [Maybe (CmmExpr, ForeignHint)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">(StgArg, StgFArgType) -&gt; FCode (Maybe (CmmExpr, ForeignHint))
</span><a href="#local-6989586621681056842"><span class="hs-identifier hs-var">get</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; [StgArg] -&gt; [StgFArgType] -&gt; [(StgArg, StgFArgType)]
forall a b. String -&gt; [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="GHC.Utils.Misc.html#zipEqual"><span class="hs-identifier hs-var">zipEqual</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;getFCallArgs&quot;</span></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621681056845"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; [StgFArgType]
</span><a href="GHC.StgToCmm.Foreign.html#collectStgFArgTypes"><span class="hs-identifier hs-var">collectStgFArgTypes</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056844"><span class="hs-identifier hs-var">typ</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-597"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, ForeignHint)] -&gt; FCode [(CmmExpr, ForeignHint)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Maybe (CmmExpr, ForeignHint)] -&gt; [(CmmExpr, ForeignHint)]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe (CmmExpr, ForeignHint)]
</span><a href="#local-6989586621681056843"><span class="hs-identifier hs-var">mb_cmms</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-598"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-599"></span><span>    </span><span id="local-6989586621681056842"><span class="annot"><span class="annottext">get :: (StgArg, StgFArgType) -&gt; FCode (Maybe (CmmExpr, ForeignHint))
</span><a href="#local-6989586621681056842"><span class="hs-identifier hs-var hs-var">get</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681056833"><span class="annot"><span class="annottext">StgArg
</span><a href="#local-6989586621681056833"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681056832"><span class="annot"><span class="annottext">StgFArgType
</span><a href="#local-6989586621681056832"><span class="hs-identifier hs-var">typ</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[PrimRep] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[PrimRep]
</span><a href="#local-6989586621681056830"><span class="hs-identifier hs-var">arg_reps</span></a></span><span>
</span><span id="line-601"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (CmmExpr, ForeignHint)
-&gt; FCode (Maybe (CmmExpr, ForeignHint))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (CmmExpr, ForeignHint)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-602"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-603"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681056829"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056829"><span class="hs-identifier hs-var">cmm</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">NonVoid StgArg -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Env.html#getArgAmode"><span class="hs-identifier hs-var">getArgAmode</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StgArg -&gt; NonVoid StgArg
forall a. a -&gt; NonVoid a
</span><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-var">NonVoid</span></a></span><span> </span><span class="annot"><span class="annottext">StgArg
</span><a href="#local-6989586621681056833"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-604"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681056826"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056826"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-605"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe (CmmExpr, ForeignHint)
-&gt; FCode (Maybe (CmmExpr, ForeignHint))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(CmmExpr, ForeignHint) -&gt; Maybe (CmmExpr, ForeignHint)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; StgFArgType -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#add_shim"><span class="hs-identifier hs-var">add_shim</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056826"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="#local-6989586621681056832"><span class="hs-identifier hs-var">typ</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056829"><span class="hs-identifier hs-var">cmm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ForeignHint
</span><a href="#local-6989586621681056824"><span class="hs-identifier hs-var">hint</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-606"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-607"></span><span>        </span><span id="local-6989586621681056823"><span class="annot"><span class="annottext">arg_ty :: Type
</span><a href="#local-6989586621681056823"><span class="hs-identifier hs-var hs-var">arg_ty</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArg -&gt; Type
</span><a href="GHC.Stg.Syntax.html#stgArgType"><span class="hs-identifier hs-var">stgArgType</span></a></span><span> </span><span class="annot"><span class="annottext">StgArg
</span><a href="#local-6989586621681056833"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-608"></span><span>        </span><span id="local-6989586621681056830"><span class="annot"><span class="annottext">arg_reps :: [PrimRep]
</span><a href="#local-6989586621681056830"><span class="hs-identifier hs-var hs-var">arg_reps</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; [PrimRep]
Type -&gt; [PrimRep]
</span><a href="GHC.Types.RepType.html#typePrimRep"><span class="hs-identifier hs-var">typePrimRep</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056823"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-609"></span><span>        </span><span id="local-6989586621681056824"><span class="annot"><span class="annottext">hint :: ForeignHint
</span><a href="#local-6989586621681056824"><span class="hs-identifier hs-var hs-var">hint</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ForeignHint
</span><a href="GHC.Cmm.Utils.html#typeForeignHint"><span class="hs-identifier hs-var">typeForeignHint</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056823"><span class="hs-identifier hs-var">arg_ty</span></a></span><span>
</span><span id="line-610"></span><span>
</span><span id="line-611"></span><span class="hs-comment">-- The minimum amount of information needed to determine</span><span>
</span><span id="line-612"></span><span class="hs-comment">-- the offset to apply to an argument to a foreign call.</span><span>
</span><span id="line-613"></span><span class="hs-comment">-- See Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-614"></span><span class="hs-keyword">data</span><span> </span><span id="StgFArgType"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgFArgType"><span class="hs-identifier hs-var">StgFArgType</span></a></span></span><span>
</span><span id="line-615"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="StgPlainType"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgPlainType"><span class="hs-identifier hs-var">StgPlainType</span></a></span></span><span>
</span><span id="line-616"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StgArrayType"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span></span><span>
</span><span id="line-617"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StgSmallArrayType"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgSmallArrayType"><span class="hs-identifier hs-var">StgSmallArrayType</span></a></span></span><span>
</span><span id="line-618"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StgByteArrayType"><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgByteArrayType"><span class="hs-identifier hs-var">StgByteArrayType</span></a></span></span><span>
</span><span id="line-619"></span><span>
</span><span id="line-620"></span><span class="hs-comment">-- See Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-621"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#add_shim"><span class="hs-identifier hs-type">add_shim</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgFArgType"><span class="hs-identifier hs-type">StgFArgType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-622"></span><span id="add_shim"><span class="annot"><span class="annottext">add_shim :: DynFlags -&gt; StgFArgType -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Foreign.html#add_shim"><span class="hs-identifier hs-var hs-var">add_shim</span></a></span></span><span> </span><span id="local-6989586621681056813"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056813"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681056812"><span class="annot"><span class="annottext">StgFArgType
</span><a href="#local-6989586621681056812"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681056811"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056811"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="#local-6989586621681056812"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-623"></span><span>  </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgPlainType"><span class="hs-identifier hs-var">StgPlainType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056811"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-624"></span><span>  </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetB"><span class="hs-identifier hs-var">cmmOffsetB</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056809"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056811"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Runtime.Heap.Layout.html#arrPtrsHdrSize"><span class="hs-identifier hs-var">arrPtrsHdrSize</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056813"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-625"></span><span>  </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgSmallArrayType"><span class="hs-identifier hs-var">StgSmallArrayType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetB"><span class="hs-identifier hs-var">cmmOffsetB</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056809"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056811"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Runtime.Heap.Layout.html#smallArrPtrsHdrSize"><span class="hs-identifier hs-var">smallArrPtrsHdrSize</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056813"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-626"></span><span>  </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgByteArrayType"><span class="hs-identifier hs-var">StgByteArrayType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; ByteOff -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetB"><span class="hs-identifier hs-var">cmmOffsetB</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681056809"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681056811"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; ByteOff
</span><a href="GHC.Runtime.Heap.Layout.html#arrWordsHdrSize"><span class="hs-identifier hs-var">arrWordsHdrSize</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056813"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-627"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-628"></span><span>    </span><span id="local-6989586621681056809"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681056809"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681056813"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span class="hs-comment">-- From a function, extract information needed to determine</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- the offset of each argument when used as a C FFI argument.</span><span>
</span><span id="line-632"></span><span class="hs-comment">-- See Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-633"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#collectStgFArgTypes"><span class="hs-identifier hs-type">collectStgFArgTypes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgFArgType"><span class="hs-identifier hs-type">StgFArgType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-634"></span><span id="collectStgFArgTypes"><span class="annot"><span class="annottext">collectStgFArgTypes :: Type -&gt; [StgFArgType]
</span><a href="GHC.StgToCmm.Foreign.html#collectStgFArgTypes"><span class="hs-identifier hs-var hs-var">collectStgFArgTypes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; Type -&gt; [StgFArgType]
</span><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-635"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-636"></span><span>    </span><span class="hs-comment">-- Skip foralls</span><span>
</span><span id="line-637"></span><span>    </span><span id="local-6989586621681056805"><span class="annot"><span class="annottext">go :: [StgFArgType] -&gt; Type -&gt; [StgFArgType]
</span><a href="#local-6989586621681056805"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681056804"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056804"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarBinder
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681056802"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056802"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; Type -&gt; [StgFArgType]
</span><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056804"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056802"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-638"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681056801"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056801"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; [StgFArgType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056801"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-639"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681056798"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056798"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; [StgFArgType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056798"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-640"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681056796"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056796"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; [StgFArgType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056796"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-641"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681056794"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056794"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; [StgFArgType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056794"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-642"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span>  </span><span class="annot"><span class="annottext">[StgFArgType]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [StgFArgType]
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;myCollectTypeArgs: CastTy&quot;</span></span><span>
</span><span id="line-643"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span>  </span><span class="annot"><span class="annottext">[StgFArgType]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; [StgFArgType]
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;myCollectTypeArgs: CoercionTy&quot;</span></span><span>
</span><span id="line-644"></span><span>    </span><span class="annot"><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681056790"><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056790"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">ft_arg :: Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681056787"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056787"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span class="hs-glyph">=</span><span id="local-6989586621681056785"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056785"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-645"></span><span>      </span><span class="annot"><span class="annottext">[StgFArgType] -&gt; Type -&gt; [StgFArgType]
</span><a href="#local-6989586621681056805"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#typeToStgFArgType"><span class="hs-identifier hs-var">typeToStgFArgType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056787"><span class="hs-identifier hs-var">arg</span></a></span><span class="annot"><span class="annottext">StgFArgType -&gt; [StgFArgType] -&gt; [StgFArgType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[StgFArgType]
</span><a href="#local-6989586621681056790"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056785"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-646"></span><span>
</span><span id="line-647"></span><span class="hs-comment">-- Choose the offset based on the type. For anything other</span><span>
</span><span id="line-648"></span><span class="hs-comment">-- than an unlifted boxed type, there is no offset.</span><span>
</span><span id="line-649"></span><span class="hs-comment">-- See Note [Unlifted boxed arguments to foreign calls]</span><span>
</span><span id="line-650"></span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#typeToStgFArgType"><span class="hs-identifier hs-type">typeToStgFArgType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Foreign.html#StgFArgType"><span class="hs-identifier hs-type">StgFArgType</span></a></span><span>
</span><span id="line-651"></span><span id="typeToStgFArgType"><span class="annot"><span class="annottext">typeToStgFArgType :: Type -&gt; StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#typeToStgFArgType"><span class="hs-identifier hs-var hs-var">typeToStgFArgType</span></a></span></span><span> </span><span id="local-6989586621681056783"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056783"><span class="hs-identifier hs-var">typ</span></a></span></span><span>
</span><span id="line-652"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#arrayPrimTyCon"><span class="hs-identifier hs-var">arrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span><span>
</span><span id="line-653"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#mutableArrayPrimTyCon"><span class="hs-identifier hs-var">mutableArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span><span>
</span><span id="line-654"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#arrayArrayPrimTyCon"><span class="hs-identifier hs-var">arrayArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span><span>
</span><span id="line-655"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#mutableArrayArrayPrimTyCon"><span class="hs-identifier hs-var">mutableArrayArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgArrayType"><span class="hs-identifier hs-var">StgArrayType</span></a></span><span>
</span><span id="line-656"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#smallArrayPrimTyCon"><span class="hs-identifier hs-var">smallArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgSmallArrayType"><span class="hs-identifier hs-var">StgSmallArrayType</span></a></span><span>
</span><span id="line-657"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#smallMutableArrayPrimTyCon"><span class="hs-identifier hs-var">smallMutableArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgSmallArrayType"><span class="hs-identifier hs-var">StgSmallArrayType</span></a></span><span>
</span><span id="line-658"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#byteArrayPrimTyCon"><span class="hs-identifier hs-var">byteArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgByteArrayType"><span class="hs-identifier hs-var">StgByteArrayType</span></a></span><span>
</span><span id="line-659"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.Prim.html#mutableByteArrayPrimTyCon"><span class="hs-identifier hs-var">mutableByteArrayPrimTyCon</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgByteArrayType"><span class="hs-identifier hs-var">StgByteArrayType</span></a></span><span>
</span><span id="line-660"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgFArgType
</span><a href="GHC.StgToCmm.Foreign.html#StgPlainType"><span class="hs-identifier hs-var">StgPlainType</span></a></span><span>
</span><span id="line-661"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-662"></span><span>  </span><span class="hs-comment">-- Should be a tycon app, since this is a foreign call. We look</span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-comment">-- through newtypes so the offset does not change if a user replaces</span><span>
</span><span id="line-664"></span><span>  </span><span class="hs-comment">-- a type in a foreign function signature with a representationally</span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-comment">-- equivalent newtype.</span><span>
</span><span id="line-666"></span><span>  </span><span id="local-6989586621681056782"><span class="annot"><span class="annottext">tycon :: TyCon
</span><a href="#local-6989586621681056782"><span class="hs-identifier hs-var hs-var">tycon</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TyCon
</span><a href="GHC.Core.Type.html#tyConAppTyCon"><span class="hs-identifier hs-var">tyConAppTyCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Types.RepType.html#unwrapType"><span class="hs-identifier hs-var">unwrapType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681056783"><span class="hs-identifier hs-var">typ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-667"></span></pre></body></html>